From 071f959a79e693cff3054e7885f37a6fe6c81e29 Mon Sep 17 00:00:00 2001 From: "rac61@labyrinth.cl.cam.ac.uk" Date: Wed, 9 Jul 2003 10:42:29 +0000 Subject: [PATCH] bitkeeper revision 1.304.1.7 (3f0bf195LrxhtbvmW2HyL5qXkoR63g) Undo silly design decision by me; namely, to do any checking of values in the Parse classes. Instead, it should be done in the Command classes, so that the web interface need not duplicate code. --- .../cmdline/ParsePartitionsAdd.java | 73 ++++++--------- .../cmdline/ParsePhysicalGrant.java | 88 ++++++++----------- .../cmdline/ParsePhysicalRevoke.java | 11 +-- .../xenoserver/cmdline/ParseVbdCreate.java | 19 +--- .../org/xenoserver/cmdline/ParseVdCreate.java | 5 +- .../org/xenoserver/cmdline/ParseVdDelete.java | 6 -- .../control/CommandPartitionAdd.java | 37 ++++++-- .../control/CommandPhysicalGrant.java | 24 ++++- .../control/CommandPhysicalRevoke.java | 13 ++- .../xenoserver/control/CommandVbdCreate.java | 14 +-- .../control/CommandVbdCreatePhysical.java | 27 +++--- .../xenoserver/control/CommandVdCreate.java | 9 +- .../xenoserver/control/CommandVdDelete.java | 5 ++ .../src/org/xenoserver/control/Partition.java | 6 +- .../org/xenoserver/control/VirtualDisk.java | 2 +- .../control/VirtualDiskManager.java | 12 +-- 16 files changed, 175 insertions(+), 176 deletions(-) diff --git a/tools/control/src/org/xenoserver/cmdline/ParsePartitionsAdd.java b/tools/control/src/org/xenoserver/cmdline/ParsePartitionsAdd.java index 041e222b4f..4076bcf51f 100644 --- a/tools/control/src/org/xenoserver/cmdline/ParsePartitionsAdd.java +++ b/tools/control/src/org/xenoserver/cmdline/ParsePartitionsAdd.java @@ -6,55 +6,38 @@ import org.xenoserver.control.CommandFailedException; import org.xenoserver.control.CommandPartitionAdd; import org.xenoserver.control.Defaults; import org.xenoserver.control.Library; -import org.xenoserver.control.Partition; -import org.xenoserver.control.PartitionManager; -import org.xenoserver.control.Settings; public class ParsePartitionsAdd extends CommandParser { - public void parse(Defaults d, LinkedList args) throws ParseFailedException, CommandFailedException { - boolean force = getFlagParameter(args, 'f'); - String partition_name = getStringParameter(args, 'p', ""); - String size = getStringParameter(args, 'c', "128M"); - - if (partition_name.equals("")) { - throw new ParseFailedException("Expected -p"); - } - - long chunksize = Library.parseSize( size ) / Settings.SECTOR_SIZE; - if ( chunksize <= 0 ) { - throw new CommandFailedException("Chunk size " + size + " is smaller than sector size."); - } - - // Initialise the partition manager and look up the partition - loadState(); - Partition p = PartitionManager.IT.getPartition(partition_name); - - if ( p == null ) { - throw new CommandFailedException("Partition " + partition_name + " does not exist."); - } - - // Check if this partition belongs to the VDM - if (p.isXeno() && !force) { - throw new CommandFailedException("Refusing to add partition as it is already allocated to the virtual disk manager. Use -f if you are sure."); - } - - String output = new CommandPartitionAdd( p, chunksize ).execute(); - if ( output != null ) { - System.out.println( output ); + public void parse(Defaults d, LinkedList args) + throws ParseFailedException, CommandFailedException { + boolean force = getFlagParameter(args, 'f'); + String partition_name = getStringParameter(args, 'p', ""); + String size = getStringParameter(args, 'c', "128M"); + + if (partition_name.equals("")) { + throw new ParseFailedException("Expected -p"); + } + + loadState(); + String output = + new CommandPartitionAdd(partition_name, Library.parseSize(size),force) + .execute(); + if (output != null) { + System.out.println(output); + } + saveState(); } - saveState(); - } - public String getName() { - return "add"; - } + public String getName() { + return "add"; + } - public String getUsage() { - return "-p [-f] [-c]"; - } + public String getUsage() { + return "-p [-f] [-c]"; + } - public String getHelpText() { - return "Add the specified partition to the virtual disk manager's free\n" + - "space. -c changes the default chunk size. -f forces add."; - } + public String getHelpText() { + return "Add the specified partition to the virtual disk manager's free\n" + + "space. -c changes the default chunk size. -f forces add."; + } } diff --git a/tools/control/src/org/xenoserver/cmdline/ParsePhysicalGrant.java b/tools/control/src/org/xenoserver/cmdline/ParsePhysicalGrant.java index 60cb925dd1..f332d5c698 100644 --- a/tools/control/src/org/xenoserver/cmdline/ParsePhysicalGrant.java +++ b/tools/control/src/org/xenoserver/cmdline/ParsePhysicalGrant.java @@ -6,60 +6,50 @@ import org.xenoserver.control.CommandFailedException; import org.xenoserver.control.CommandPhysicalGrant; import org.xenoserver.control.Defaults; import org.xenoserver.control.Mode; -import org.xenoserver.control.Partition; -import org.xenoserver.control.PartitionManager; public class ParsePhysicalGrant extends CommandParser { - public void parse(Defaults d, LinkedList args) throws ParseFailedException, CommandFailedException { - int domain_id = getIntParameter(args, 'n', 0); - boolean force = getFlagParameter(args, 'f'); - String partition_name = getStringParameter(args, 'p', ""); - boolean write = getFlagParameter(args, 'w'); - - if (domain_id == 0) { - throw new ParseFailedException("Expected -n"); - } - if (partition_name.equals("")) { - throw new ParseFailedException("Expected -p"); - } - - Mode mode; - if (write) { - mode = Mode.READ_WRITE; - } else { - mode = Mode.READ_ONLY; - } - - // Initialise the partition manager and look up the partition - loadState(); - Partition p = PartitionManager.IT.getPartition(partition_name); - - if ( p == null ) { - throw new CommandFailedException("Partition " + partition_name + " does not exist."); - } - - // Check if this partition belongs to the VDM - if (p.isXeno() && !force) { - throw new CommandFailedException("Refusing to grant physical access as the given partition is allocated to the virtual disk manager. Use -f if you are sure."); - } - - String output = new CommandPhysicalGrant( d, domain_id, p, mode ).execute(); - if ( output != null ) { - System.out.println( output ); + public void parse(Defaults d, LinkedList args) + throws ParseFailedException, CommandFailedException { + int domain_id = getIntParameter(args, 'n', 0); + boolean force = getFlagParameter(args, 'f'); + String partition_name = getStringParameter(args, 'p', ""); + boolean write = getFlagParameter(args, 'w'); + + if (domain_id == 0) { + throw new ParseFailedException("Expected -n"); + } + if (partition_name.equals("")) { + throw new ParseFailedException("Expected -p"); + } + + Mode mode; + if (write) { + mode = Mode.READ_WRITE; + } else { + mode = Mode.READ_ONLY; + } + + // Initialise the partition manager and look up the partition + loadState(); + String output = + new CommandPhysicalGrant(d, domain_id, partition_name, mode, force) + .execute(); + if (output != null) { + System.out.println(output); + } } - } - public String getName() { - return "grant"; - } + public String getName() { + return "grant"; + } - public String getUsage() { - return "-n -p [-f] [-w]"; - } + public String getUsage() { + return "-n -p [-f] [-w]"; + } - public String getHelpText() { - return "Grant the specified domain access to the given partition. -w grants" + - " read-write instead of read-only. -f forcibly grants access."; - } + public String getHelpText() { + return "Grant the specified domain access to the given partition. -w grants" + + " read-write instead of read-only. -f forcibly grants access."; + } } diff --git a/tools/control/src/org/xenoserver/cmdline/ParsePhysicalRevoke.java b/tools/control/src/org/xenoserver/cmdline/ParsePhysicalRevoke.java index 1f075b4708..56d37e6dac 100644 --- a/tools/control/src/org/xenoserver/cmdline/ParsePhysicalRevoke.java +++ b/tools/control/src/org/xenoserver/cmdline/ParsePhysicalRevoke.java @@ -5,8 +5,6 @@ import java.util.LinkedList; import org.xenoserver.control.CommandFailedException; import org.xenoserver.control.CommandPhysicalRevoke; import org.xenoserver.control.Defaults; -import org.xenoserver.control.Partition; -import org.xenoserver.control.PartitionManager; public class ParsePhysicalRevoke extends CommandParser { public void parse(Defaults d, LinkedList args) @@ -23,14 +21,7 @@ public class ParsePhysicalRevoke extends CommandParser { // Initialise the partition manager and look up the partition loadState(); - Partition p = PartitionManager.IT.getPartition(partition_name); - - if (p == null) { - throw new CommandFailedException( - "Partition " + partition_name + " does not exist."); - } - - String output = new CommandPhysicalRevoke(d, domain_id, p).execute(); + String output = new CommandPhysicalRevoke(d, domain_id, partition_name).execute(); if (output != null) { System.out.println(output); } diff --git a/tools/control/src/org/xenoserver/cmdline/ParseVbdCreate.java b/tools/control/src/org/xenoserver/cmdline/ParseVbdCreate.java index bae98b33e5..54713b45fc 100644 --- a/tools/control/src/org/xenoserver/cmdline/ParseVbdCreate.java +++ b/tools/control/src/org/xenoserver/cmdline/ParseVbdCreate.java @@ -7,10 +7,6 @@ import org.xenoserver.control.CommandVbdCreate; import org.xenoserver.control.CommandVbdCreatePhysical; import org.xenoserver.control.Defaults; import org.xenoserver.control.Mode; -import org.xenoserver.control.Partition; -import org.xenoserver.control.PartitionManager; -import org.xenoserver.control.VirtualDisk; -import org.xenoserver.control.VirtualDiskManager; public class ParseVbdCreate extends CommandParser { public void parse(Defaults d, LinkedList args) @@ -41,21 +37,10 @@ public class ParseVbdCreate extends CommandParser { loadState(); String output; if (vd_key.equals("")) { - Partition p = PartitionManager.IT.getPartition(partition_name); - if ( p == null ) { - throw new CommandFailedException("No partition " + partition_name + " exists" ); - } - - output = new CommandVbdCreatePhysical( p, domain_id, vbd_num, mode ).execute(); + output = new CommandVbdCreatePhysical( partition_name, domain_id, vbd_num, mode ).execute(); } else { - VirtualDisk vd = VirtualDiskManager.IT.getVirtualDisk(vd_key); - if (vd == null) { - throw new CommandFailedException( - "No virtual disk with key " + vd_key); - } - output = - new CommandVbdCreate(vd, domain_id, vbd_num, mode).execute(); + new CommandVbdCreate(vd_key, domain_id, vbd_num, mode).execute(); } if (output != null) { System.out.println(output); diff --git a/tools/control/src/org/xenoserver/cmdline/ParseVdCreate.java b/tools/control/src/org/xenoserver/cmdline/ParseVdCreate.java index 3aaeb967ac..ccacfb3954 100644 --- a/tools/control/src/org/xenoserver/cmdline/ParseVdCreate.java +++ b/tools/control/src/org/xenoserver/cmdline/ParseVdCreate.java @@ -9,7 +9,6 @@ import org.xenoserver.control.CommandFailedException; import org.xenoserver.control.CommandVdCreate; import org.xenoserver.control.Defaults; import org.xenoserver.control.Library; -import org.xenoserver.control.Settings; public class ParseVdCreate extends CommandParser { public void parse(Defaults d, LinkedList args) @@ -39,9 +38,7 @@ public class ParseVdCreate extends CommandParser { long size = Library.parseSize(size_s); loadState(); - String output = - new CommandVdCreate(name, size / Settings.SECTOR_SIZE, expiry) - .execute(); + String output = new CommandVdCreate(name, size, expiry).execute(); if (output != null) { System.out.println(output); } diff --git a/tools/control/src/org/xenoserver/cmdline/ParseVdDelete.java b/tools/control/src/org/xenoserver/cmdline/ParseVdDelete.java index 6d4f838c4e..cfbce4a423 100644 --- a/tools/control/src/org/xenoserver/cmdline/ParseVdDelete.java +++ b/tools/control/src/org/xenoserver/cmdline/ParseVdDelete.java @@ -5,7 +5,6 @@ import java.util.LinkedList; import org.xenoserver.control.CommandFailedException; import org.xenoserver.control.CommandVdDelete; import org.xenoserver.control.Defaults; -import org.xenoserver.control.VirtualDiskManager; public class ParseVdDelete extends CommandParser { public void parse(Defaults d, LinkedList args) @@ -17,11 +16,6 @@ public class ParseVdDelete extends CommandParser { } loadState(); - if (VirtualDiskManager.IT.getVirtualDisk(vd_key) == null) { - throw new CommandFailedException( - "Virtual disk " + vd_key + " does not exist"); - } - String output = new CommandVdDelete(vd_key).execute(); if (output != null) { System.out.println(output); diff --git a/tools/control/src/org/xenoserver/control/CommandPartitionAdd.java b/tools/control/src/org/xenoserver/control/CommandPartitionAdd.java index 72d1bb631b..37db9dff69 100644 --- a/tools/control/src/org/xenoserver/control/CommandPartitionAdd.java +++ b/tools/control/src/org/xenoserver/control/CommandPartitionAdd.java @@ -4,27 +4,46 @@ package org.xenoserver.control; * Add a disk partition to the VirtualDiskManager as a XenoPartition. */ public class CommandPartitionAdd extends Command { + /** True to force creation. */ + private boolean force; /** Partition to add as a XenoPartition. */ - private Partition partition; - /** Chunk size to split partition into (in sectors). */ + private String partition_name; + /** Chunk size to split partition into (in bytes). */ private long chunksize; /** * Constructor for CommandPartitionAdd. - * @param partition Partition to add. - * @param chunksize Chunk size to split partition into (in sectors). + * @param partition_name Partition to add. + * @param chunksize Chunk size to split partition into (in bytes). + * @param force True to force creation. */ - public CommandPartitionAdd(Partition partition, long chunksize) { - this.partition = partition; + public CommandPartitionAdd(String partition_name, long chunksize, boolean force) { + this.partition_name = partition_name; this.chunksize = chunksize; + this.force = force; } /** * @see org.xenoserver.control.Command#execute() */ public String execute() throws CommandFailedException { - VirtualDiskManager.IT.addPartition(partition, chunksize); - PartitionManager.IT.addXenoPartition(partition); - return "Added partition " + partition.getName(); + Partition p = PartitionManager.IT.getPartition(partition_name); + if (p == null) { + throw new CommandFailedException( + "Partition " + partition_name + " does not exist."); + } + // Check if this partition belongs to the VDM + if (p.isXeno() && !force) { + throw new CommandFailedException("Refusing to add partition as it is already allocated to the virtual disk manager. Use -f if you are sure."); + } + + long size = chunksize / Settings.SECTOR_SIZE; + if ( chunksize <= 0 ) { + throw new CommandFailedException("Chunk size is smaller than sector size."); + } + + VirtualDiskManager.IT.addPartition(p, size); + PartitionManager.IT.addXenoPartition(p); + return "Added partition " + p.getName(); } } diff --git a/tools/control/src/org/xenoserver/control/CommandPhysicalGrant.java b/tools/control/src/org/xenoserver/control/CommandPhysicalGrant.java index ab56ad65e1..0288f32c98 100644 --- a/tools/control/src/org/xenoserver/control/CommandPhysicalGrant.java +++ b/tools/control/src/org/xenoserver/control/CommandPhysicalGrant.java @@ -9,9 +9,11 @@ public class CommandPhysicalGrant extends Command { /** Domain ID to grant access for */ private int domain_id; /** Partition to grant access to */ - private Partition partition; + private String partition_name; /** Access mode to grant */ private Mode mode; + /** True to force grant */ + private boolean force; /** * Constructor for CommandPhysicalGrant. @@ -19,16 +21,19 @@ public class CommandPhysicalGrant extends Command { * @param domain_id Domain to grant access for. * @param partition Partition to grant access to. * @param mode Access mode to grant. + * @param force True to force grant */ public CommandPhysicalGrant( Defaults d, int domain_id, - Partition partition, - Mode mode) { + String partition, + Mode mode, + boolean force) { this.d = d; this.domain_id = domain_id; - this.partition = partition; + this.partition_name = partition; this.mode = mode; + this.force = force; } /** @@ -38,6 +43,17 @@ public class CommandPhysicalGrant extends Command { Runtime r = Runtime.getRuntime(); String output = null; + Partition partition = PartitionManager.IT.getPartition(partition_name); + + if ( partition == null ) { + throw new CommandFailedException("Partition " + partition_name + " does not exist."); + } + + // Check if this partition belongs to the VDM + if (partition.isXeno() && !force) { + throw new CommandFailedException("Refusing to grant physical access as the given partition is allocated to the virtual disk manager. Use -f if you are sure."); + } + try { Process start_p; String start_cmdarray[] = new String[7]; diff --git a/tools/control/src/org/xenoserver/control/CommandPhysicalRevoke.java b/tools/control/src/org/xenoserver/control/CommandPhysicalRevoke.java index 22473c5beb..71d2efa457 100644 --- a/tools/control/src/org/xenoserver/control/CommandPhysicalRevoke.java +++ b/tools/control/src/org/xenoserver/control/CommandPhysicalRevoke.java @@ -9,7 +9,7 @@ public class CommandPhysicalRevoke extends Command { /** Domain to revoke access from */ private int domain_id; /** Partition to revoke access to */ - private Partition partition; + private String partition_name; /** * Constructor for CommandPhysicalRevoke. @@ -17,10 +17,10 @@ public class CommandPhysicalRevoke extends Command { * @param domain_id Domain to revoke access from. * @param partition Partition to revoke access to. */ - public CommandPhysicalRevoke(Defaults d, int domain_id, Partition partition) { + public CommandPhysicalRevoke(Defaults d, int domain_id, String partition) { this.d = d; this.domain_id = domain_id; - this.partition = partition; + this.partition_name = partition; } /** @@ -30,6 +30,13 @@ public class CommandPhysicalRevoke extends Command { Runtime r = Runtime.getRuntime(); String output = null; + Partition partition = PartitionManager.IT.getPartition(partition_name); + + if (partition == null) { + throw new CommandFailedException( + "Partition " + partition_name + " does not exist."); + } + try { Process start_p; String start_cmdarray[] = new String[5]; diff --git a/tools/control/src/org/xenoserver/control/CommandVbdCreate.java b/tools/control/src/org/xenoserver/control/CommandVbdCreate.java index 2b7f150878..8ac0883264 100644 --- a/tools/control/src/org/xenoserver/control/CommandVbdCreate.java +++ b/tools/control/src/org/xenoserver/control/CommandVbdCreate.java @@ -8,7 +8,7 @@ import java.io.IOException; */ public class CommandVbdCreate extends Command { /** Virtual disk to map to. */ - private VirtualDisk vd; + private String vd_key; /** Domain to create VBD for. */ private int domain_id; /** VBD number to use. */ @@ -24,11 +24,11 @@ public class CommandVbdCreate extends Command { * @param mode Access mode to grant. */ public CommandVbdCreate( - VirtualDisk vd, + String vd, int domain_id, int vbd_num, Mode mode) { - this.vd = vd; + this.vd_key = vd; this.domain_id = domain_id; this.vbd_num = vbd_num; this.mode = mode; @@ -38,9 +38,13 @@ public class CommandVbdCreate extends Command { * @see org.xenoserver.control.Command#execute() */ public String execute() throws CommandFailedException { - VirtualBlockDevice vbd; + VirtualDisk vd = VirtualDiskManager.IT.getVirtualDisk(vd_key); + if (vd == null) { + throw new CommandFailedException( + "No virtual disk with key " + vd_key); + } - vbd = + VirtualBlockDevice vbd = VirtualDiskManager.IT.createVirtualBlockDevice( vd, domain_id, diff --git a/tools/control/src/org/xenoserver/control/CommandVbdCreatePhysical.java b/tools/control/src/org/xenoserver/control/CommandVbdCreatePhysical.java index b804ef2ac9..2046525529 100644 --- a/tools/control/src/org/xenoserver/control/CommandVbdCreatePhysical.java +++ b/tools/control/src/org/xenoserver/control/CommandVbdCreatePhysical.java @@ -8,7 +8,7 @@ import java.io.IOException; */ public class CommandVbdCreatePhysical extends Command { /** Virtual disk to map to. */ - private Partition partition; + private String partition_name; /** Domain to create VBD for. */ private int domain_id; /** VBD number to use. */ @@ -24,11 +24,11 @@ public class CommandVbdCreatePhysical extends Command { * @param mode Access mode to grant. */ public CommandVbdCreatePhysical( - Partition partition, + String partition, int domain_id, int vbd_num, Mode mode) { - this.partition = partition; + this.partition_name = partition; this.domain_id = domain_id; this.vbd_num = vbd_num; this.mode = mode; @@ -38,14 +38,17 @@ public class CommandVbdCreatePhysical extends Command { * @see org.xenoserver.control.Command#execute() */ public String execute() throws CommandFailedException { - VirtualDisk vd = new VirtualDisk("vbd:"+partition.getName()); - vd.addPartition(partition,partition.getNumSects()); + Partition partition = PartitionManager.IT.getPartition(partition_name); + if (partition == null) { + throw new CommandFailedException( + "No partition " + partition_name + " exists"); + } + + VirtualDisk vd = new VirtualDisk("vbd:" + partition.getName()); + vd.addPartition(partition, partition.getNumSects()); - VirtualBlockDevice vbd = new VirtualBlockDevice( - vd, - domain_id, - vbd_num, - mode); + VirtualBlockDevice vbd = + new VirtualBlockDevice(vd, domain_id, vbd_num, mode); String command = vd.dumpForXen(vbd); @@ -55,7 +58,9 @@ public class CommandVbdCreatePhysical extends Command { fw.flush(); fw.close(); } catch (IOException e) { - throw new CommandFailedException("Could not write VBD details to /proc/xeno/dom0/vhd", e); + throw new CommandFailedException( + "Could not write VBD details to /proc/xeno/dom0/vhd", + e); } return "Created virtual block device " diff --git a/tools/control/src/org/xenoserver/control/CommandVdCreate.java b/tools/control/src/org/xenoserver/control/CommandVdCreate.java index 4187b49890..d8cdb247d0 100644 --- a/tools/control/src/org/xenoserver/control/CommandVdCreate.java +++ b/tools/control/src/org/xenoserver/control/CommandVdCreate.java @@ -8,7 +8,7 @@ import java.util.Date; public class CommandVdCreate extends Command { /** Name of new disk. */ private String name; - /** Size of new disk in sectors. */ + /** Size of new disk in bytes. */ private long size; /** Expiry date of new disk. */ private Date expiry; @@ -16,7 +16,7 @@ public class CommandVdCreate extends Command { /** * Constructor for CommandVdCreate. * @param name Name of new virtual disk. - * @param size Size in sectors. + * @param size Size in bytes. * @param expiry Expiry time, or null for never. */ public CommandVdCreate(String name, long size, Date expiry) { @@ -30,7 +30,10 @@ public class CommandVdCreate extends Command { */ public String execute() throws CommandFailedException { VirtualDisk vd = - VirtualDiskManager.IT.createVirtualDisk(name, size, expiry); + VirtualDiskManager.IT.createVirtualDisk( + name, + size / Settings.SECTOR_SIZE, + expiry); if (vd == null) { throw new CommandFailedException("Not enough free space to create disk"); } diff --git a/tools/control/src/org/xenoserver/control/CommandVdDelete.java b/tools/control/src/org/xenoserver/control/CommandVdDelete.java index 5243cae566..6fadde859c 100644 --- a/tools/control/src/org/xenoserver/control/CommandVdDelete.java +++ b/tools/control/src/org/xenoserver/control/CommandVdDelete.java @@ -19,6 +19,11 @@ public class CommandVdDelete extends Command { * @see org.xenoserver.control.Command#execute() */ public String execute() throws CommandFailedException { + if (VirtualDiskManager.IT.getVirtualDisk(key) == null) { + throw new CommandFailedException( + "Virtual disk " + key + " does not exist"); + } + VirtualDiskManager.IT.deleteVirtualDisk(key); return "Deleted virtual disk " + key; } diff --git a/tools/control/src/org/xenoserver/control/Partition.java b/tools/control/src/org/xenoserver/control/Partition.java index 7cfc918f29..bc1e7e7c09 100644 --- a/tools/control/src/org/xenoserver/control/Partition.java +++ b/tools/control/src/org/xenoserver/control/Partition.java @@ -142,7 +142,7 @@ public class Partition { * @param other Other partition to compare to. * @return True if they are identical. */ - public boolean identical(Partition other) { + boolean identical(Partition other) { return this.major == other.major && this.minor == other.minor && this.blocks == other.blocks @@ -154,7 +154,7 @@ public class Partition { /** * @return An Extent covering this partiton. */ - public Extent toExtent() { + Extent toExtent() { return new Extent(getDisk(),start_sect,nr_sects); } @@ -162,7 +162,7 @@ public class Partition { * @param e Extent to compare this partition to. * @return True if this partition covers the same disk area as the given extent. */ - public boolean matchesExtent(Extent e) { + boolean matchesExtent(Extent e) { return e.getDisk() == getDisk() && e.getOffset() == start_sect && e.getSize() == nr_sects; diff --git a/tools/control/src/org/xenoserver/control/VirtualDisk.java b/tools/control/src/org/xenoserver/control/VirtualDisk.java index 8bacadbb49..f99085788d 100644 --- a/tools/control/src/org/xenoserver/control/VirtualDisk.java +++ b/tools/control/src/org/xenoserver/control/VirtualDisk.java @@ -227,7 +227,7 @@ public class VirtualDisk { * Reset the expiry time for this virtual disk. * @param expiry The new expiry time, or null for never. */ - public void refreshExpiry(Date expiry) { + void refreshExpiry(Date expiry) { this.expiry = expiry; } } diff --git a/tools/control/src/org/xenoserver/control/VirtualDiskManager.java b/tools/control/src/org/xenoserver/control/VirtualDiskManager.java index 7ac5e79e4d..e872790dba 100644 --- a/tools/control/src/org/xenoserver/control/VirtualDiskManager.java +++ b/tools/control/src/org/xenoserver/control/VirtualDiskManager.java @@ -45,7 +45,7 @@ public class VirtualDiskManager { * @param partition The partition to add. * @param chunkSize The chunk size to split the partition into, in sectors. */ - public void addPartition(Partition partition, long chunkSize) { + void addPartition(Partition partition, long chunkSize) { freeDisk.addPartition(partition, chunkSize); } @@ -56,7 +56,7 @@ public class VirtualDiskManager { * @param expiry The expiry time, or null for never. * @return null if not enough space is available */ - public VirtualDisk createVirtualDisk(String name, long size, Date expiry) { + VirtualDisk createVirtualDisk(String name, long size, Date expiry) { if (freeDisk.getSize() < size) { return null; } @@ -83,7 +83,7 @@ public class VirtualDiskManager { * Delete a virtual disk, and put its extents back into the free pool. * @param key The key of the disk to delete. */ - public void deleteVirtualDisk(String key) { + void deleteVirtualDisk(String key) { VirtualDisk vd; vd = (VirtualDisk) virtualDisks.get(key); @@ -108,7 +108,7 @@ public class VirtualDiskManager { * @param mode The mode to create the device with. * @return The newly created virtual block device. */ - public VirtualBlockDevice createVirtualBlockDevice( + VirtualBlockDevice createVirtualBlockDevice( VirtualDisk vd, int domain, int vbdNum, @@ -126,7 +126,7 @@ public class VirtualDiskManager { * @param domain Domain owning the device. * @param vbdNum The vbd number within the domain. */ - public void deleteVirtualBlockDevice(int domain, int vbdNum) { + void deleteVirtualBlockDevice(int domain, int vbdNum) { Object hash = hashVBD(domain, vbdNum); virtualBlockDevices.remove(hash); } @@ -134,7 +134,7 @@ public class VirtualDiskManager { /** * Flush all virtual block devices. */ - public void flushVirtualBlockDevices() { + void flushVirtualBlockDevices() { /* isn't automatic garbage collection wonderful? */ virtualBlockDevices = new LinkedHashMap(100); } -- 2.30.2